/*-------------------------------------------------------------------------*/
/**
  @file		execrefine_params.h
  @author	Renaud Wanchoor
  @date	July 2004
  @version	$Revision: 2.7 $
  @brief	parameters for the execution time refinement
  
*/
/*--------------------------------------------------------------------------*/

#ifndef EXECREFINE_PARAMS_H
#define EXECREFINE_PARAMS_H

#define MAX_IM 		1.02 /**< \brief maximum imbalance tolerance */
#define DIFFUSE         1    /**< \brief Activation of the load balancing stage.
			      *
			      * 1: load balancing activated, 0: not activated */
/*#define KL              1 */   /**< \brief Activation of the KL stage.
			      *
			      *1: kl stage activated, 0: not activated */
#define MAX_KLMOVES     30   /**< \brief maximum size of the recent move list in the kl stage */
#define VREFCONTSIZE	200  /**< \brief initial size of the array that contains boundary vertices */
#define MOVE_ONCE       20   /**< \brief maximum number of reassignment for a single vertex during one level of uncoarsening, if set to 0 there is no limit */

#define FILTEREXECFROM FILTEREXECFROM1 /**< \brief filter for processors in the moving from stage */
#define FILTEREXECTO   FILTEREXECTO1 /**< \brief filter for processors in the moving to stage */
#define IMTHRESHOLD    IMTHRESHOLD2 /**< \brief  macro that computed the imbalance tolerance */

#define IMTHRESHOLD1(max,levels,ctrl) ((ctrl)->level==0?max:MAX(max,1+sqrt((double)((ctrl)->n->npro)/(ctrl)->g->father->nvtxs)))
#define IMTHRESHOLD2(max,levels,ctrl) max
#define IMTHRESHOLD3(max,levels,ctrl) ((ctrl)->level<levels/2?max:INFINITY)
#define IMTHRESHOLD4(max,levels,ctrl) INFINITY
#define IMTHRESHOLD5(max,levels,ctrl) ((ctrl)->level<1*levels/3?max:INFINITY)

#define FILTEREXECFROM1(Rctrl,tf) ((((Rctrl)->im<MAX_IM) || 			\
				    ((tf)>(Rctrl)->tmean))?			\
				   1:0)

#define FILTEREXECTO1(Rctrl,tt) ((((Rctrl)->im<MAX_IM) || 			\
				    ((tt)<(Rctrl)->tmean))?			\
				   1:0)

#define OneFromFilter  Filter /**< \brief filter function to use in the moving from stage */
#define OneToFilter    Filter /**< \brief filter function to use in the moving to stage */
#define KlFilter       FilterKl /**< \brief filter function to use in the kl stage */
#define TwoFromFilter  FilterDiffuse /**< \brief filter function to use in the moving from load balancing stage */
#define TwoToFilter    FilterDiffuse /**< \brief filter function to use in the moving to load balancing stage */

#define KlUndo         UndoKl /**< \brief undo function to use in the kl stage */

#define OneGain        GainFlow /**< \brief gain function to use in the local refinement stage */
#define KlGain         GainFlow /**< \brief gain function to use in the KL stage */
#define TwoGain        GainFlow /**< \brief gain function to use in the load balancing stage */

#define UNDO_INI        1 /**< controlling macro */ 
#define UNDO_UPDATE     2 /**< controlling macro */ 
#define UNDO_TEST       3 /**< controlling macro */ 
#define UNDO_DEBUG      4 /**< controlling macro */ 

#define UNDO_NOTHING    0 /**< controlling macro */ 
#define UNDO_UNDO       1 /**< controlling macro */ 
#define UNDO_APPLY      2 /**< controlling macro */ 


#endif
